package cn.sx.guoxd.springboot.controller;

import cn.sx.guoxd.springboot.dao.UserDao;
import cn.sx.guoxd.springboot.model.User;
import cn.sx.guoxd.springboot.util.PageRowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/users")
public class UsersController {
    private final UserDao userDao;

    public UsersController(UserDao userDao) {
        this.userDao = userDao;
    }

    @GetMapping
    public ResponseEntity<List<User>> list(){
        PageRowBounds pageRowBounds = new PageRowBounds(0,2);
        List<User> list = userDao.getList(pageRowBounds);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }
}
